package com.nagarro.factory;

import com.nagarro.inventory.ImportedItem;
import com.nagarro.inventory.Item;
import com.nagarro.inventory.ManufacturedItem;
import com.nagarro.inventory.RawItem;
import com.nagarro.util.Constants;

/**
 * Factory class to create an Item based on the type spcecified by the user.
 * @author uditverma
 *
 */
public class ItemFactory {

	// use getItem method to get object of type item
	public Item getItem(String itemType) {
		if (itemType == null) {
			return null;
		}
		if (Constants.RAW_ITEM.equalsIgnoreCase(itemType)) {
			return new RawItem();
		} else if (Constants.MANUFACTURED_ITEM.equalsIgnoreCase(itemType)) {
			return new ManufacturedItem();
		} else if (Constants.IMPORTED_ITEM.equalsIgnoreCase(itemType)) {
			return new ImportedItem();
		}
		System.err.println(Constants.ERROR_INVALID_ITEM_TYPE);
		return null;
	}

}
